package com.lennon.desinge.observer.pull;

import java.util.ArrayList;
import java.util.List;

public abstract class PullSubject {
	/**
	 * ��������ע��Ĺ۲��߶���
	 */
	private List<PullObserver> list = new ArrayList<PullObserver>();

	/**
	 * ע��۲��߶���
	 * 
	 * @param observer
	 *            �۲��߶���
	 */
	public void attach(PullObserver observer) {

		list.add(observer);
		System.out.println("Attached an observer");
	}

	/**
	 * ɾ���۲��߶���
	 * 
	 * @param observer
	 *            �۲��߶���
	 */
	public void detach(PullObserver observer) {

		list.remove(observer);
	}

	/**
	 * ֪ͨ����ע��Ĺ۲��߶���
	 */
	public void nodifyObservers() {

		for (PullObserver observer : list) {
			observer.update(this);
		}
	}
}
